<!doctype html>

<html>

  <head>
    <meta charset="utf-8">
    <title>WASM compileStreaming() test</title>
  </head>

  <body>


    <script>
      const importObject = {
        my_namespace: {
          imported_func: arg => {
            console.log(arg);
          }
        }
      };

      // equivalent:
      // fetch("simple.wasm")
      // .then(response => response.arrayBuffer())
      // .then(bytes => WebAssembly.compile(bytes))
      // .then(module => WebAssembly.instantiate(module, importObject))
      // .then(instance => { instance.exports.exported_func(); });

      WebAssembly.compileStreaming(fetch("simple.wasm"))
      .then(module => WebAssembly.instantiate(module, importObject))
      .then(instance => {
        instance.exports.exported_func();
      });
    </script>
  </body>

</html>
